package com.zens.cms.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zens.cms.entity.UserSiteManage;
import com.zens.cms.entity.UserSiteManageExample;
import com.zens.cms.entity.UserSiteManageExample.Criteria;
import com.zens.cms.mapper.UserSiteManageMapper;
import com.zens.cms.services.IUserSiteMangeService;

@Service
public class UserSiteManageService implements IUserSiteMangeService {
	
	@Resource
	UserSiteManageMapper mapper;
	
	public List<UserSiteManage> query(Long uid) {
		UserSiteManageExample example = new UserSiteManageExample();
		Criteria criteria = example.createCriteria();
		criteria.andFuseridEqualTo(uid);
		return mapper.selectByExample(example);
	}

	public int delete(Long uid) {
		UserSiteManageExample example = new UserSiteManageExample();
		Criteria criteria = example.createCriteria();
		criteria.andFuseridEqualTo(uid);
		return mapper.deleteByExample(example);
	}

	public int add(UserSiteManage manage) {
		return mapper.insertSelective(manage);
	}

	/* (non-Javadoc)
	 * @see com.evmtv.cms.services.IUserSiteMangeService#querySite(java.lang.Long)
	 */
	@Override
	public List<Long> querySite(Long uid) {
		UserSiteManageExample example = new UserSiteManageExample();
		Criteria criteria = example.createCriteria();
		criteria.andFuseridEqualTo(uid);
		return mapper.selectSiteIDByExample(example);
	}

	@Override
	public int deleteBySiteId(List<Long> siteIds) {
		UserSiteManageExample example = new UserSiteManageExample();
		Criteria criteria = example.createCriteria();
		criteria.andFsiteidIn(siteIds);
		return mapper.deleteByExample(example);
	}

}
